<template>
	<view class="download">
		<view class="download-img-box">
			<image class="download-img" :src="app_info.app_bg?baseUrl+app_info.app_bg:'/static/public/images/download-bg.png'" mode="widthFix"></image>
			<image v-if="app_info.app_ios_path !== undefined && app_info.app_ios_path !== ''" @click="downloadIos" class="download-btn" src="/static/public/images/ios.png" mode="widthFix"></image>
			<image v-if="app_info.app_apk_path !== undefined && app_info.app_apk_path !== ''" @click="downloadAndroid" class="download-btn android" src="/static/public/images/android.png" mode="widthFix"></image>
		</view>
		<view class="download-info">
			<view class="download-logo">
				<img class="logo-img" :src="app_info.app_logo?baseUrl+app_info.app_logo:'/static/public/images/logo.png'" mode="widthFix" >
			</view>
			<view class="download-title">{{app_info.app_name}}</view>
		</view>
		<view class="model" v-if="is_weixin">
			<image class="shareTips" src="/static/public/images/zhiyin.png" mode="widthFix"></image>
		</view>
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				is_weixin:false,
				baseUrl:this.config.baseUrl,
				app_info:{
					app_name:'',
					app_logo:'',
					app_bg:'',
					app_ios_path:'',
					app_apk_path:'',
				}
			}
		},onLoad(options) {
			console.log(6666)
			let _this = this;
			// #ifdef H5
			let ua = window.navigator.userAgent.toLowerCase()
			if (ua.match(/MicroMessenger/i) == 'micromessenger') {
				_this.is_weixin = true
			}
			// #endif
			let setting = uni.getStorageSync("setting");
			console.log(setting);
			_this.app_info.app_name = setting.app_name;
			_this.app_info.app_logo = setting.app_logo;
			_this.app_info.app_bg = setting.app_bg;
			_this.app_info.app_ios_path = setting.app_ios_path;
			_this.app_info.app_apk_path = setting.app_apk_path;
			console.log(_this.app_info);
		},
		methods: {
			downloadAndroid:function(){
				let _this = this;
				let url = _this.baseUrl + _this.app_info.app_apk_path;
				window.location.href = url
			},
			downloadIos:function(){
				let _this = this;
				let url = _this.app_info.app_ios_path;
				window.location.href = url
			}
		}
	}
</script>
<style  lang="scss">
	.download{
		width: 100%;
		height: 100%;
		top: 0;
		right: 0;
		.download-img-box{
			width: 100%;
			position: relative;
			top: 0;
			left: 0;
			.download-img{
				width: 100%;
				position: absolute;
				top: 0;
				left: 0;
			}
			.download-btn{
				width: 330rpx;
				position: absolute;
				top: 620rpx;
				left: 50%;
				transform: translateX(-50%);
				z-index: 100;
			}
			.download-btn.android{
				top: 750rpx;
			}
		}
		.download-info{
			width: 100%;
			position: absolute;
			top: 1050rpx;
			text-align: center;
			z-index: 200;
			// left: 50%;
			// transform: translateX(-50%);
			.logo-img{
				width: 160rpx;
			}
			.download-title{
				font-size: 36rpx;
				font-weight: 600;
				margin-top: 20rpx;
			}
		}
	}
	.model{
		position: fixed;
		width: 100%;
		height: 100%;
		background-color: rgba(0,0,0,0.6);
		z-index: 300;
		.shareTips{
			width: 100%;
		}
	}
</style>
